﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class top : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Permission"] != null)
            {
                Permission permission = Session["Permission"] as Permission;
                lblUserName.Text = permission.UserName;

                UserBLL ubll = new UserBLL(permission);
                ViolationNoticeBLL vbll = new ViolationNoticeBLL(permission);

                DataSet vnds = vbll.GetAllViolationNoticeView("and userid=" + permission.UserID.ToString());
                DataSet ds = ubll.GetUserView(permission.UserID);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    double GuardLine = SwiftConverter.CovertDBObjectToDouble(dr["GuardLine"]);
                    double CurrentIntegral = SwiftConverter.CovertDBObjectToDouble(dr["CurrentIntegral"]);
                    if (GuardLine >= CurrentIntegral)
                    {
                        lblGuardLine.Text = "您目前的积分已经到达或低于警戒线! ";
                    }
                    int IsSafetyEducation = Convert.ToInt32(dr["IsSafetyEducation"]);
                    if (IsSafetyEducation == 0)
                    {
                        lblGuardLine.Text += (string.IsNullOrEmpty(lblGuardLine.Text) ? "" : "|") + "您目前未接受安全教育! ";
                    }

                    if (vnds != null && vnds.Tables.Count > 0 && vnds.Tables[0].Rows.Count > 0)
                    {
                        lblGuardLine.Text += (string.IsNullOrEmpty(lblGuardLine.Text) ? "" : "|") + "您目前有违规记录! ";
                    }
                }
            }
        }
    }
}